package br.com.center.loja.ws.dto.converter;

import java.util.ArrayList;
import java.util.List;

import br.com.center.loja.model.Neighborhood;
import br.com.center.loja.ws.dto.NeighborhoodDTO;

public class NeighborhoodDTOConverter implements Converter<Neighborhood, NeighborhoodDTO>
{
	private CityDTOConverter city = new CityDTOConverter();
	@Override
	public NeighborhoodDTO to(Neighborhood element) {
		NeighborhoodDTO dto = new NeighborhoodDTO();
		dto.setCode(element.getCode());
		dto.setName(element.getName());
		dto.setState(element.getState());
		dto.setAcronym(element.getAcronym());
		dto.setCity(city.to(element.getCity()));		
		return dto;
	}

	@Override
	public Neighborhood from(NeighborhoodDTO element) {
		Neighborhood dto = new Neighborhood();
		dto.setCode(element.getCode());
		dto.setName(element.getName());
		dto.setState(element.getState());
		dto.setAcronym(element.getAcronym());
		dto.setCity(city.from(element.getCity()));		
		return dto;
	}
	
	@Override
	public List<NeighborhoodDTO> to(List<Neighborhood> elements) {
		List<NeighborhoodDTO> result = new ArrayList<NeighborhoodDTO>();
		for(Neighborhood element : elements){
			result.add(to(element));
		}		
		return result;
	}
	
	@Override
	public List<Neighborhood> from(List<NeighborhoodDTO> elements) {
		List<Neighborhood> result = new ArrayList<Neighborhood>();
		for(NeighborhoodDTO element : elements){
			result.add(from(element));
		}		
		return result;
	}


}
